package apollo.generator.common.base;

import io.swagger.annotations.ApiModelProperty;
import lombok.AccessLevel;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;
import org.slf4j.MDC;

/**
 * <Description>
 * 基础的返回VO
 * @author Jun Lee
 * @version 1.0
 * @createDate 2020-03-27 18:15:36
 */
@Data
@Accessors(chain = true)
@AllArgsConstructor(access = AccessLevel.PROTECTED)
@NoArgsConstructor(access = AccessLevel.PROTECTED)
public class R<T> {
    @ApiModelProperty(value = "返回码")
    protected Integer code = IBaseResponseCode.SUCCESS_CODE;

    @ApiModelProperty(value = "返回消息")
    protected String msg = IBaseResponseCode.SUCCESS_MESSAGE;

    @ApiModelProperty(value = "返回数据")
    protected T data;

    @ApiModelProperty(value = "请求ID")
    protected String requestId = MDC.get("requestId");

    @ApiModelProperty(value = "响应状态(true - 成功 , false -失败)")
    protected boolean status = IBaseResponseCode.SUCCESS_STATUS;


    protected static R getInstance(){
        return new R();
    }
}
